using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;

namespace ElasticReflection.Emit
{

    public class ElasticEmit
    {
        public static EmitAssembly Assembly(string Name, string Module)
        {
            var AB = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(Name), AssemblyBuilderAccess.RunAndSave);
            var MB = AB.DefineDynamicModule(Module);

            return new EmitAssembly(AB, MB);
        }
    }

    public class EmitAssembly
    {
        ModuleBuilder MB;
        AssemblyBuilder AB;

        internal EmitAssembly(AssemblyBuilder AB, ModuleBuilder MB)
        {
            this.AB = AB;
            this.MB = MB;
        }

        public EmitType DefineType(string Name)
        {
            return new EmitType(MB.DefineType(Name), this);
        }

        

        public Assembly End()
        {
            return AB;
        }


    }
}
